# -*- coding: utf-8 -*-
"""
Created on Wed Mar 27 23:17:26 2019

@author: ikaros
"""

import numpy as np
import xlwt #只支持xls文件

data_file = 'name.txt'
##创建工作簿
book = xlwt.Workbook() 

first=[]

with open(data_file, 'r') as f1:
    for line in f1:
        line = line.strip()
        print(type(line))
        line = line.split(' ') #按空格切分字符串
#        print(line)          #debug
#        line= np.array(line) #debug
#        print(line.shape)    #debug
        first.append(line)
        
first = np.array(first)
#print(first) #debug
#print(first.shape)#debug
row1,col1 = first.shape
#print(i,j) #debug

sheet1 = book.add_sheet(u'sheet1',cell_overwrite_ok=True) # 创建表单
for i in range(row1):
    for j in range(col1):
        sheet1.write(i,j,first[i][j])

book.save('test.xls')
